package pers.amos.eshop.advance.product.mapper;

import org.apache.ibatis.annotations.*;
import pers.amos.eshop.advance.product.model.ProductSpecification;


@Mapper
public interface ProductSpecificationMapper {

    @Insert("INSERT INTO product_specification(name,value,product_id) VALUES(#{name},#{value},#{productId})")
    @Options(keyColumn = "id", keyProperty = "id", useGeneratedKeys = true)
    void add(ProductSpecification productSpecification);

    @Update("UPDATE product_specification SET name=#{name},value=#{value},product_id=#{productId} WHERE id=#{id}")
    void update(ProductSpecification productSpecification);

    @Delete("DELETE FROM product_specification WHERE id=#{id}")
    void delete(Long id);

    @Select("SELECT * FROM product_specification WHERE id=#{id}")
    ProductSpecification findById(Long id);

    @Select("SELECT * FROM product_property WHERE product_id=#{productId}")
    ProductSpecification findByProductId(Long productId);
}
